{extend name="public/base"/}
{block name="style"}
<link rel="stylesheet" href="__PUBLIC__/css/order.css">
<style>
    #product-more-btn {top: 30px;line-height: 30px;}
    #product-more-btn button { width: 100%;}
    .carousel-img{cursor:pointer;}
</style>
{/block}
{block name="content"}
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12 Order">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-tab">
                        <div class="layui-tab-content">
                            <div class="layui-tab-item screen-box">
                                <div class="layui-form-item channel product-select">
                                    <label class="layui-form-label">商品状态</label>
                                    <div class="layui-input-block">
                                        <ul>
                                            <li item="product_status="><a class="active">全部</a></li>
                                            {foreach name="product_status" id="p" key="k"}
                                            <li item="status={$k}"><a>{$p}</a></li>
                                            {/foreach}
                                        </ul>
                                    </div>
                                </div>
                                <div class="layui-form-item channel product-select">
                                    <label class="layui-form-label">录入时间</label>
                                    <div class="layui-input-block">
                                        <ul>
                                            <li item="create_date="><a class="active">全部</a></li>
                                            {foreach name="create_date" id="create" key="key"}
                                            <li item="create_date={$key}"><a>{$create}</a></li>
                                            {/foreach}
                                        </ul>
                                    </div>
                                </div>
                                <div class="layui-form-item channel product-select">
                                    <label class="layui-form-label">排序方式</label>
                                    <div class="layui-input-block">
                                        <ul>
                                            <li item="sort="><a class="active">默认</a></li>
                                            {foreach name="sort" id="st" key="key"}
                                            <li item="sort={$key}"><a>{$st}</a></li>
                                            {/foreach}
                                        </ul>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">商品录入时间</label>
                                    <div class="layui-input-inline" style="width: 220px;">
                                        <input class="layui-input laydate-range" id="start_date" autocomplete="off" name="date" placeholder="录入时间">
                                    </div>
                                    <button type="button" class="layui-btn layui-btn layui-btn-normal search-btn"><i
                                            class="layui-icon layui-icon-search"></i></button>
                                </div>
                            </div>
                            <div class="layui-tab-item layui-show">
                                <form class="layui-form">
                                    <div class="layui-col-md1 layui-row">
                                        <select id="select_product" lay-search lay-filter="select_product">
                                            {foreach name="select_product" id="item" key="key"}
                                            <option value="{$key}">{$item}</option>
                                            {/foreach}
                                        </select>
                                    </div>
                                    <div class="layui-col-md2 layui-row">
                                        <input id="product_name" placeholder="按回车搜索" class="layui-input"/>
                                    </div>
                                    <div class="layui-col-md2 layui-row">
                                        <div class="layui-input-block" style="margin: 0px;">
                                        <input type="text" id="product-category" name="category_id" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-col-md2 layui-row">
                                        <a class="layui-btn layui-btn-normal product-select-down"><span>更多</span>&nbsp;&nbsp;<i
                                                class="fa fa-angle-double-down" aria-hidden="true"></i></a>
                                    </div>
                                    {php}if(isset($other_filter)):{/php}
                                        {foreach name="other_filter" id="filter" key="f"}
                                            <input type="hidden" class="other-filter" name="{$f}" value="{$filter}"/>
                                        {/foreach}
                                    {php}endif;{/php}
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-btn-group">
                        <button type="button" id="remove-all" class="layui-btn layui-btn-sm layui-btn-normal"><i
                                class="layui-icon layui-icon-delete"></i>批量删除
                        </button>
                        <a href="/attachment/template/product-template.xlsx?v=1"
                           class="layui-btn layui-btn-sm layui-btn-normal"><i
                                class="layui-icon layui-icon-download-circle"></i>下载模板</a>
                        <button type="button" id="import-product" class="layui-btn layui-btn-sm layui-btn-normal"><i
                                class="layui-icon layui-icon-upload-drag"></i>导入商品
                        </button>
                        <button type="button" id="export-product" class="layui-btn layui-btn-sm layui-btn-normal"><i
                                class="layui-icon layui-icon-export"></i>导出商品
                        </button>
                        <button type="button" id="add-product" class="layui-btn layui-btn-sm layui-btn-normal"><i
                                class="layui-icon layui-icon-add-circle"></i>录入商品
                        </button>
                        <ul class="layui-nav layui-bg-green btnz"
                            style="font-size: 12px;border-radius: 0px;float: right;padding:0px;margin-left: 2px;">
                            <li class="layui-nav-item" style="line-height: 30px;font-size: 12px;">
                                <a class="layui-btn layui-btn-sm layui-btn-normal"
                                   style="color:white;font-size: 12px;padding: 0px 30px 0px 20px;">更多<span
                                        class="layui-nav-more" style="right: 10px;font-size: 12px;"></span></a>
                                <dl class="layui-nav-child" id="product-more-btn"> <!-- 二级菜单 -->
                                    <dd>
                                        <button type="button" id="batch-move-category"
                                                class="layui-btn layui-btn-sm layui-btn-normal">移动分类
                                        </button>
                                    </dd>
                                    <dd>
                                        <button type="button" id="batch-edit-status"
                                                class="layui-btn layui-btn-sm layui-btn-normal">修改状态
                                        </button>
                                    </dd>
                                    <dd>
                                        <button type="button" id="batch-platform-sku"
                                                class="layui-btn layui-btn-sm layui-btn-normal">生成平台SKU
                                        </button>
                                    </dd>
                                    <dd>
                                        <button type="button" id="batch-remark"
                                                class="layui-btn layui-btn-sm layui-btn-normal">批量备注
                                        </button>
                                    </dd>
                                </dl>
                            </li>
                        </ul>
                    </div>
                    <table class="layui-hide" id="commodity" lay-filter="commodity"></table>
                </div>
            </div>
        </div>
    </div>
<!--轮播图-->
<script type="text/html" id="carousel-html">
    <div class="layui-carousel" id="carousel-list">
        <div carousel-item>

        </div>
    </div>
</script>
<!-- 生成平台SKU -->
<script type="text/html" id="platform-sku-box">
    <div class="layui-col-md12">
        <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">账号</label>
            <div class="layui-input-block">
                <select id="platform-sku-account" lay-search>
                    <option value="">请选择账号</option>
                    {foreach $account as $a}
                    <option value="{$a.account_id}">{$a.username?:$a.store_name}</option>
                    {/foreach}}
                </select>
            </div>
        </div>
        </form>
    </div>
</script>
<!--操作-->
<script type="text/html" id="operation">
    <div>
        <button style="margin-bottom: 3px;" lay-event="look" type="button" class="layui-btn layui-btn-sm"><i
            class="layui-icon layui-icon-search"></i></button><br>
        <button style="margin-bottom: 3px;" lay-event="edit" type="button"
                class="layui-btn layui-btn-sm layui-btn-warm"><i class="layui-icon layui-icon-edit"></i></button>
        <br>
        <button type="button" lay-event="del" class="layui-btn layui-btn-sm layui-btn-danger"><i
                class="layui-icon layui-icon-delete"></i></button>
    </div>
</script>
<!-- 修改商品状态-->
<script type="text/html" id="edit-product-status">
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-body">
                <div class="layui-form-item channel product-status-select">
                    <label class="layui-form-label">商品状态</label>
                    <div class="layui-input-block">
                        <ul>
                            {foreach $status as $k => $v}
                                <li item="status={$k}"><a>{$v}</a></li>
                            {/foreach}
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</script>
<!-- 修改商品分类-->
<script type="text/html" id="edit-product-category">
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-body">
                <div class="layui-form-item channel product-status-select">
                    <label class="layui-form-label">商品分类</label>
                    <div class="layui-input-block">
                        <input type="text" id="product-category-edit" name="category_id" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
    </div>
</script>
{/block}
{block name="script"}
    <script type="text/javascript">
        layui.config({
            base: '__PUBLIC__/layui/plugins/'
        }).use('selectGroupTree');
        layui.use(['form', 'laydate', 'table', 'upload', 'layer', 'selectGroupTree', 'carousel'], function () {
            var form = layui.form
                , layer = layui.layer
                , laydate = layui.laydate
                , table = layui.table
                , upload = layui.upload
                , selectGroupTree = layui.selectGroupTree
                , carousel = layui.carousel;

            //展示已知数据
            table.render({
                elem: '#commodity'
                , page: true
                , url: '{:url("wms/product/index")}?' + $.param(getOtherFilter())
                //, toolbar: '#toolbarDemo'
                , title: '商品数据表'
                , height: 'full-200'
                , cols: [[ //标题栏
                    {type: 'checkbox'},
                    {
                        field: 'image_url', title: '图片', width: 130, templet: function (row) {
                            var s, imgs = [];
                            if(row.images)for(let i in row.images) imgs.push(row.images[i].path);
                            s = imgs.join(",");
                           return `<div><img class="carousel-img" src="${row.image_url}"><span class="layui-hide">${s}<span></div>`;
                        }
                    }
                    , {
                        field: 'info', title: '商品名称', width: 450, templet: function (row) {
                            return `<p>SKU：${row.stores[0].sku}</p>
                                    <p>中文名：${row.name_ch}</p>
                                    <p>英文名：${row.name_en}</p>
                                    <p>分类：${row.category.name}</p>
                                   `;
                        }
                    }
                    , {field: 'status', width: 90, title: '状态'}
                    , {
                        field: 'size', title: '商品信息', width: 150, templet: function (row) {
                            return `<div>
                                    <p>长：${row.stores[0].length > 0 ? row.stores[0].length + '（mm）' : ''}</p>
                                    <p>宽：${row.stores[0].width > 0 ? row.stores[0].width + '（mm）' : ''}</p>
                                    <p>高：${row.stores[0].height > 0 ? row.stores[0].height + '（mm）' : ''}</p>
                                    <p>重量：<span class="layui-badge">${row.stores[0].weight > 0 ? row.stores[0].weight + '（g）' : ''}</span></p>
                                </div>`;
                        }
                    }
                    ,{
                        field: 'price', title: '默认采购', width: 150, templet: function (row) {
                            var surl = "";

                            if(row.purchase && row.purchase.length > 0)
                            {
                                for(let i in row.purchase)
                                {
                                    if(row.purchase[i].is_default == 1 || row.purchase[i].is_default == '是')
                                    {
                                        if(row.purchase[i].url.length > 0) surl = `<a target="_blank" href="${row.purchase[i].url}"><i class="layui-icon layui-icon-link"></i></a>`;
                                        break;
                                    }
                                }
                            }
                            return `
                                <p>价格：${row.price > 0 ? row.price : ''}</p>
                                <p>链接：${surl}</p>
                                <p>供应商：${row.default_purchase}</p>
                                `;
                        }
                    }
                    , {field: 'remark', title: '备注', edit: 'text'}
                    , {
                        field: 'date', title: '时间', width: 200, templet: function (row) {
                            return `
                                <p>录入：${row.create_time}</p>
                                <p>修改：${row.update_time}</p>
                                `;
                        }
                    }
                    , {field: 'experience', title: '操作', width: 70, fixed: "right", toolbar: '#operation'}
                ]]
                //,skin: 'line' //表格风格
                , even: true
                , limits: [100, 150, 300, 500]
                , limit: 100 //每页默认显示的数量
            });

            //监听单元格编辑
            table.on('edit(commodity)', function (obj) {
                var value = obj.value //得到修改后的值
                    , data = obj.data //得到所在行所有键值
                    , field = obj.field; //得到字段
                var params = {field, value};
                params["product_id"] = data.product_id;
                $.post("{:url('/wms/product/update')}", params).done(function(response)
                {
                    var icon = response.code == 0 ? 6 : 5;
                    layer.msg(response.msg, {icon: icon, time: 1500});
                });
            });

            // 图片轮播
            $("body").on("click", ".carousel-img", function()
            {
                var imgs = $(this).siblings().text().split(",");
                if(imgs.length < 1) return;
                layer.open({
                    btn: [],
                    title: '图片列表',
                    area: ['550px', '45%'],
                    content: $("#carousel-html").html()
                    , success: function (layero, index) {
                        var html = "";
                        for(let i in imgs) html += `<img style="max-width: 500px;" src="${imgs[i]}"/>`;
                        $("#carousel-list > div").html(html);
                        carousel.render({
                            elem: '#carousel-list'
                            ,width: '100%' //设置容器宽度
                            ,arrow: 'always' //始终显示箭头
                            //,anim: 'updown' //切换动画方式
                        });
                    }
                });
            });

            // 商品搜索
            $(".search-btn").click(function () {
                var $where = {};
                $("div.product-select li a.active").each(function (i, e) {
                    var item = $(e).parent().attr("item").split("=");
                    if (item[1]) $where[item[0]] = item[1];
                });
                var logistics = $("#select_logistics option:selected").val(),
                    cate = $("#product-category").val(),
                    productVal = $("#product_name").val().trim(),
                    start_date = $("#start_date").val().trim();
                if (productVal) $where[$("#select_product option:selected").val()] = productVal;
                if (cate) $where["category_id"] = cate;
                if (logistics) $where["logistics_name"] = logistics;
                if (start_date) $where["start_date"] = start_date;
                $where = $.extend($where, getOtherFilter());
                // if($.isEmptyObject($where)) return;
                var url = "{:url('/wms/product/index')}" + ($.isEmptyObject($where) ? "" : "?" + $.param($where));
                table.reload("commodity", {
                    url: url,
                    page: {
                        curr: 1 //重新从第 1 页开始
                    },
                    // where: $where,
                    // done: function(){console.log(this.where);}
                });
            });

            selectGroupTree.ajax({
                elem: 'product-category', //ID名称
                url: '{:url("/wms/category/getTree")}', //数据请求地址
                type: 'get', //请求方式
                dataType: 'json', //数据类型
                data: null, //传递到服务端的数据
                placeholder: '' //占位符
                , callback: function (obj)
                {
                    setTimeout(()=>{reloadProductTable();}, 100);
                }
            });

            form.on('select(select_product)', function (data) {
                if ($("#product_name").val().trim() != "") reloadProductTable();
            });

            // 监听输入框回车
            $("#product_name").keyup(function (event) {
                if (event.keyCode == 13) reloadProductTable();
            });

            //监听行工具事件
            table.on('tool(commodity)', function (obj) {
                var data = obj.data;
                if (obj.event === 'del') {
                    layer.confirm('真的删除商品？', function (index) {
                        deleteProduct(data.product_id, function () {
                            obj.del();
                            layer.close(index);
                        });
                    });
                }
                else if (obj.event === 'edit') {
                    layer.open({
                        type: 2,
                        title: '编辑商品',
                        area: ['80%', '80%'],
                        content: '{:url("wms/product/edit")}?product_id=' + data.product_id
                    });
                } else if (obj.event === 'look') {
                    layer.open({
                        type: 2,
                        title: '商品详情',
                        area: ['90%', '80%'],
                        content: '{:url("wms/product/look")}?product_id=' + data.product_id
                    });
                }
            });

            // 录入商品
            $("#add-product").click(function()
            {
                layer.open({
                    type: 2,
                    title: '编辑商品',
                    area: ['80%', '80%'],
                    content: '{:url("wms/product/edit")}'
                });
            });

            function getOtherFilter()
            {
                var other = {};
                $("input.other-filter").each(function()
                {
                    other[$(this).attr("name")] = $(this).val();
                });
                return other;
            }
            // 刷新表格商品
            function reloadProductTable() {
                $(".search-btn").click();
                form.render('select');
            }

            /**
             * 删除商品
             * @param productId  商品id 可多个
             * @param fn 回调函数
             */
            function deleteProduct(productId, fn) {
                $.get("{:url('wms/product/delete')}", {ids: productId}).done(function (response) {
                    var icon = response.code == 0 ? 6 : 5;
                    if(response.code == 0)
                    {
                        layer.msg(response.msg, {icon: icon, time: 1500}, fn ? fn : null);
                    }
                    else
                    {
                        layer.msg(response.msg, {icon: icon, time: 1500});
                    }
                });
            }

            // 导入商品
            upload.render({
                elem: '#import-product'
                , url: '{:url("file/upload",["type"=>"document"])}'
                , accept: 'file' //普通文件
                , exts: 'xlsx|xls|csv' // 指定类型
                , field: "file"
                , before: function (obj) {
                    layer.load(0, {shade: false});
                }
                , done: function (response, index, upload) {
                    if (response.code != 0) {
                        layer.closeAll('loading');
                        var icon = response.code == 0 ? 6 : 5;
                        layer.msg(response.msg, {icon: icon, time: 1500});
                        return;
                    }
                    $.post("{:url('wms/product/import')}", {"path": response.data.src}).done(function (res) {
                        layer.closeAll('loading');
                        var icon = 5, time = 5500;
                        if (res.code == 0) {
                            icon = 6;
                            time = 1500;
                        }
                        var icon = res.code == 0 ? 6 : 5;
                        layer.msg(res.msg.replaceAll("\n", "<br/>"), {icon, time}, function () {
                            if (res.code == 0) reloadProductTable();
                        });
                    });
                }
                , error: function (index, upload) {
                    layer.msg('上传失败');
                }
            });

            // 导出商品
            $("#export-product").click(function () {
                var data = table.checkStatus("commodity").data;
                var ids = [];
                for (let i in data) ids.push(data[i].product_id);
                var start_date = $("#start_date").val().trim();
                if (!data.length && !start_date) return layer.msg('请选择要导出的商品');
                layer.load(0, {shade: false});
                $.get("{:url('wms/product/export')}", {ids, start_date}).done(function (response) {
                    layer.closeAll('loading');
                    response.code == 0
                        ? location.href = "{:url('file/download')}?file=" + response.data.src
                        : layer.msg(response.msg, {icon: 5, time: 1500});
                });
            });

            // 批量删除商品
            $("#remove-all").click(function () {
                var data = table.checkStatus("commodity").data,
                    dataLen = data.length;
                if (!dataLen > 0) return layer.msg('请选择要删除的商品');
                layer.confirm(`你真的要删除【${dataLen}】个商品吗？`, {btn: ['确认删除', '取消']}, function (index) {
                    layer.close(index);
                    layer.load(0, {shade: false});
                    var ids = [];
                    for (let i in data) ids.push(data[i].product_id);
                    /*$("div.layui-table-body table tbody input[name='layTableCheckbox']:checked").each(function()
                    {
                        var n = $(this).parents("tbody tr").index();  // 获取checkbox所在行的顺序
                        $("div.layui-table-body table tbody ").find("tr:eq(" + n + ")").remove(); // 移除行
                        //如果是全选移除，就将全选CheckBox还原为未选中状态
                        $("div.layui-table-header table thead div.layui-unselect.layui-form-checkbox").removeClass("layui-form-checked");
                    });*/
                    deleteProduct(ids.join(","), function () {
                        reloadProductTable();
                        layer.closeAll('loading');
                    });
                });
            });

            // 批量生成平台 SKU
            $("#batch-platform-sku").click(function()
            {
                var data = table.checkStatus("commodity").data;
                if (data.length < 1)
                {
                    layer.msg("请选择要生成的商品");
                    return;
                }
                generatePlatformSku(function(account)
                {
                    var data = table.checkStatus("commodity").data
                        , ids = [];
                    for(let i in data) ids.push(data[i].product_id);
                    layer.load(0, {shade: false});
                    var params = {"account_id":account, "product_id": ids.join(",")};
                    $.post("{:url('wms/platform/generateSku')}", params).done(function(response)
                    {
                        layer.closeAll('loading');
                        var icon = response.code == 0 ? 6 : 5;
                        layer.msg(response.msg, {icon: icon, time: 1500});
                    });
                });
            });

            function generatePlatformSku(fn)
            {
                layer.open({
                    title: '生成平台SKU',
                    area: ['40%', '40%'],
                    content: $("#platform-sku-box").html()
                    , success: function (layero, index)
                    {
                        form.render('select');
                    }
                    , yes: function (index, layero)
                    {
                        var account = $("#platform-sku-account").val();
                        if(!account) return false;
                        if(typeof fn === "function") fn(account);
                        layer.close(index);
                    }
                });
            }

            // 批量备注
            $("#batch-remark").click(function () {
                var data = table.checkStatus("commodity").data;
                if (data.length < 1) {
                    layer.msg("请选择要备注的商品");
                    return;
                }
                var ids = [];
                for (let i in data) ids.push(data[i].product_id);
                layer.prompt({title: '批量备注商品', formType: 2}, function (text, index) {
                    layer.close(index);
                    $.post("{:url('wms/product/update')}", {
                        product_id: ids.join(","),
                        field: "remark",
                        value: text
                    }).done(function (response) {
                        var icon = response.code == 0 ? 6 : 5;
                        layer.msg(response.msg, {icon: icon, time: 1500});
                        reloadProductTable();
                    });
                });
            });

            // 点击筛选商品状态
            $("body").on("click", ".product-status-select li", function () {
                var $this = $(this);
                $this.siblings().find("a").removeClass("active");
                $this.find("a").addClass("active");
            });

            // 修改商品状态
            $("#batch-edit-status").click(function () {
                var data = table.checkStatus("commodity").data;
                if (data.length < 1)
                {
                    layer.msg("请选择要修改的商品");
                    return;
                }
                openEditProductStatus(function(params)
                {
                    var data = table.checkStatus("commodity").data,
                        ids = [];
                    for (let i in data) ids.push(data[i].product_id);
                    params["product_id"] = ids.join(',');
                    $.post("{:url('/wms/product/update')}", params).done(function (response) {
                        var icon = response.code == 0 ? 6 : 5;
                        layer.msg(response.msg, {icon: icon, time: 1500});
                        reloadProductTable();
                    });
                });
            });

            // 打开弹窗更新商品状态
            function openEditProductStatus(fn)
            {
                layer.open({
                    title: '修改商品状态',
                    area: ['40%', '30%'],
                    content: $("#edit-product-status").html()
                    , yes: function (index, layero) {
                        var params = {
                            "field": [],
                            "value": []
                        };
                        $(".product-status-select .active").each(function () {
                            let t = $(this).parent().attr("item").split("=");
                            params.field.push(t[0]);
                            params.value.push(t[1]);
                        });
                        layer.close(index);
                        if(params.field.length < 1) return;
                        if(typeof fn === "function") fn(params);
                    }
                });
            }

            // 移动分类
            $("#batch-move-category").click(function()
            {
                var data = table.checkStatus("commodity").data;
                if (data.length < 1)
                {
                    layer.msg("请选择要移动的商品");
                    return;
                }
                layer.open({
                    title: '修改商品分类',
                    area: ['40%', '60%'],
                    content: $("#edit-product-category").html()
                    , success: function (layero, index)
                    {
                        selectGroupTree.ajax({
                            elem: 'product-category-edit', //ID名称
                            url: '{:url("/wms/category/getTree")}', //数据请求地址
                            type: 'get', //请求方式
                            dataType: 'json', //数据类型
                            data: null, //传递到服务端的数据
                            placeholder: '' //占位符
                        });
                    }
                    , yes: function (index, layero) {
                        var cateId = $.trim($("#product-category-edit").val());
                        if(!cateId) return;
                        var ids = [];
                        for (let i in data) ids.push(data[i].product_id);
                        layer.close(index);
                        $.post("{:url('wms/product/update')}", {
                            product_id: ids.join(","),
                            field: "category_id",
                            value: cateId
                        }).done(function (response) {
                            var icon = response.code == 0 ? 6 : 5;
                            layer.msg(response.msg, {icon: icon, time: 1500});
                            reloadProductTable();
                        });
                    }
                });
            });

            // 点击筛选
            $(".product-select li").click(function () {
                var $this = $(this);
                $this.siblings().find("a").removeClass("active");
                $this.find("a").addClass("active");
                reloadProductTable();
            });

            // 展示更多筛选项
            $(".product-select-down").click(function () {
                var $this = $(this), $box = $(".screen-box");
                $box.toggle("fast");
                if ($box.data("c")) {
                    $box.data("c", 0);
                    $this.find("span").text("更多");
                    $this.find("i").removeClass("fa-angle-double-up").addClass("fa-angle-double-down");
                } else {
                    $box.data("c", 1);
                    $this.find("span").text("收起");
                    $this.find("i").removeClass("fa-angle-double-down").addClass("fa-angle-double-up");
                }
            });

            // 重置表格大小
            resetTableSize(table, "commodity");
        });
    </script>
{/block}
